import request from '@/utils/request'

// 查询列表
export function flowTemplateList(query) {
  return request({
    url: '/flow/template/list',
    method: 'get',
    params: query
  })
}

export function flowTemplateInfo(id) {
  return request({
    url: `/flow/template/${id}`,
    method: 'get'
  })
}

export function flowTemplateInfoByCode(code) {
  return request({
    url: '/flow/template/code',
    method: 'get',
    params: {
      code
    }
  })
}

// 新增流程模板
export function addFlowTemplate(data) {
  return request({
    url: '/flow/template',
    method: 'post',
    data: data
  })
}

// 修改流程模板
export function updateFlowTemplate(id, data) {
  return request({
    url: `/flow/template/${id}`,
    method: 'put',
    data: data
  })
}

export function allTables() {
  return request({
    url: '/flow/template/tables',
    method: 'get'
  })
}

export function allColumns(table) {
  return request({
    url: `/flow/template/columns/${table}`,
    method: 'get'
  })
}

// 修改流程模板
export function deleteFlowTemplate(id) {
  return request({
    url: `/flow/template/${id}`,
    method: 'delete',
  })
}

// 角色状态修改
export function changeFlowTemplateStatus(id, status) {
  return request({
    url: `/flow/template/changeStatus/${id}`,
    method: 'put',
    data: {
      status
    }
  })
}
